package com.onemile.controls;

import java.util.ArrayList;

import com.onemile.app.R;
import com.onemile.entity.model.EAttribute;
import com.onemile.entity.model.EAttributeDetails;
import com.onemile.entity.model.ECommodityAccessories;
import com.onemile.entity.model.ECoupon;
import com.onemile.entity.model.EPromotions;
import com.onemile.entity.model.ESpecification;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdpLV_DialogSingleSelect extends BaseAdapter
{
   private ArrayList<?> mList;
   private Context mContext;
   private LayoutInflater mInflater;

   // public interface CallBack
   // {
   //
   // }

   public AdpLV_DialogSingleSelect(ArrayList<?> list, Context context)
   {
	  mList = list;
	  mContext = context;
	  mInflater = LayoutInflater.from(context);

   }

   @Override
   public int getCount()
   {
	  return mList.size();
   }

   @Override
   public Object getItem(int position)
   {
	  return mList.get(position);
   }

   @Override
   public long getItemId(int position)
   {
	  return 0;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent)
   {
	  convertView = mInflater.inflate(R.layout.dialog_single_select_item, null);
	  TextView txtItem = (TextView) convertView.findViewById(R.id.txtItem_dialog_single_item);
	  Object item = mList.get(position);
	  if (item instanceof EAttributeDetails)
	  {
		 txtItem.setText(((EAttributeDetails) item).getAttributeDetailsName());
	  }
	  else if (item instanceof ESpecification)
	  {
		 txtItem.setText(((ESpecification) item).getSpecificationName());
	  }
	  else if (item instanceof ECommodityAccessories)
	  {
		 txtItem.setText(((ECommodityAccessories) item).getCommodityAccessoriesName());
	  }
	  else if (item instanceof EPromotions)
	  {
		 txtItem.setText(((EPromotions) item).getPromotionsTitle());
	  }
	  else if (item instanceof ECoupon)
	  {
		 txtItem.setText(((ECoupon) item).getCouponName());
	  }
	  else if (item instanceof String)
	  {
		 txtItem.setText(item.toString());
	  }

	  return convertView;
   }

}
